﻿using AutoMapper;
using B.S.Sterilizationcenter.Domain.yjb;
using B.S.Sterilizationcenter.ErrorCode;
using B.S.Sterilizationcenter.Read.API.Appliaction.Commends.yjb;
using MediatR;
using SqlSugar;

namespace B.S.Sterilizationcenter.Read.API.Appliaction.CommandHandlers.yjb
{
    public class ShowResultItemInfoCommandHandlers:IRequestHandler<ShowResultItemInfoCommand,ApiResult<List<ResultItemInfo>>>
    {
        private readonly ISqlSugarClient db;
        private readonly IMapper mapper;

        public ShowResultItemInfoCommandHandlers(ISqlSugarClient db, IMapper mapper)
        {
            this.db = db;
            this.mapper = mapper;
        }
        /// <summary>
        /// 检查显示
        /// </summary>
        /// <param name="request"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        public async Task<ApiResult<List<ResultItemInfo>>> Handle(ShowResultItemInfoCommand request, CancellationToken cancellationToken)
        {
            try
            {
                ApiResult<List<ResultItemInfo>> result = new ApiResult<List<ResultItemInfo>>();
                var list = db.Queryable<ResultItemInfo>().Where(x => x.IsDElet == false).ToList();
                result.Code = ApiEnums.查询成功;
                result.Msg = "查询成功";
                result.Data = list;
                return result;
            }
            catch (Exception)
            {
                throw;
            }
        }
    }
}
